#include"sqlist.h"
void printNode(sl*phead)
{
	assert(phead);
	sl* cur = phead->next;
	while (cur != NULL)
	{
		printf("%d ", cur->val);
	}
}

sl * CreatNewNode(SQDataType x)
{
	sl* newnode = (sl*)malloc(sizeof(sl));
	if (newnode == NULL)
	{
		perror("malloc fail");
		exit(-1);
	}
	newnode->val = x;
	newnode->next = NULL;
	return newnode;
}
sl* Initsqlist()
{
	sl* phead = CreatNewNode(-1);
	phead->next = phead;
	return phead;
}
void InsertPushBack(sl* phead, SQDataType x)
{
	assert(phead);
	sl* newnode = CreatNewNode(x);
	if (phead->next == NULL)
	{
		phead->next = newnode;
	}
	else
	{
		sl* cur = phead->next;
		if (cur->next != NULL)
		{
			cur = cur->next;
		}
		cur->next = newnode;

	}
}
//void InsertPushFront(sl* phead, SQDataType x)
//{
//	assert(phead);
//	sl* newnode = CreatNewNode(x);
//	if (phead->next == NULL)
//	{
//		phead->next = newnode;
//		newnode->next = NULL;
//	}
//	else
//	{
//		sl* cur = phead->next;
//		phead->next = newnode;
//		newnode->next = cur;
//		cur->next = NULL;
//	}
//}
	

	
